<?php
class ASolicitudProduccionCotizacion {

	public function __construct() {
	}

	public function generarRP(EFacade & $facade) {
		$spc = & $facade->getDocumentRoot();				
		$req = $facade->session->create('DRequerimientoProduccion');
		$req->epSetCommittable(FALSE,FALSE);
		$role = NULL; 
		$req->estado = 1;
		$req->producto = $spc->producto;
		$req->metodo = $spc->producto->usaLaMatriz[0]->metodoUsado;
		$req->cantidad = $spc->cantidad;
		$req->asociadoACotizacion = $spc;
		$facade2 = & EFacade :: initWorkflow($facade->session, $req, $role);
		$facade2->saveWorkflow();
		$transSet = EFacade :: getCurrentTransSet($facade2->getWorkflow(), $role);
		$trans = $transSet->getTransByName('t1');
		$usr=NULL;
		$facade2->fireTrans($trans, $usr, "Crear",TRUE);
		$req->epSetCommittable(TRUE);
		$req->epSetDirty(TRUE);
		$facade2->saveWorkflow();
		$req->commit();
		$req->numero = $req->getDocumentNumber();
		$req->diferenciador=$req->getDocumentDifer();
		$req->commit();
		$docCP = & $facade->getDocumentRoot();
		$workflowCP = & $facade->getWorkflow();
		$transSetCP = & EFacade :: getCurrentTransSetAuto($workflowCP, /* MTrans :: $TYPE_AUTO_AGENT */ 2);
		$transCP = $transSetCP->getTransByName('t2');
		$facade->fireTrans($transCP,$usr,'generar RP', TRUE);
	}
}
?>